/*****************************************************************************
 *
 * proxjs-x-menu.js -- inline script for sidki's Proxomitron config
 *
 * This script gets injected via XMLHttpRequest once you left-click on a page
 * element that isn't a link.  Unless you've unticked "Add Proxomitron Menu"
 * in the Web Filters Config Control section.  There's also a fall-back for
 * older browsers, where it gets inserted as external script.
 *
 * Last edited: 2009-02-05
 *
 *****************************************************************************/

/* ====================================
   Write the menu.
   ==================================== */

(function () {
  var x = [], here = window.location, url = prxO.oAss.asUesc(prxO.oMen.meSet[8]), path, base;

  if (here.protocol.match(/^(about|keyword):/)) {
    var urlA = url.match(/^([^:]+:\/\/[^\/]+)(\/([^\/?]+\/)*)/);
    path = urlA[0];
    base = urlA[1];
  } else {
    base = here.protocol; base += "//"; base += here.host;
    path = base; path += here.pathname;
  }

  for (var i = 0, hasJS = 0, scr = prxO.oInt.inGetEl("script"), sc; sc = scr[i]; i++)
    if (sc.id.indexOf("proxScr") != 0) hasJS++;

  var hostA = url.match(/:\/\/([^\/]+)/)[1],
  wname = (typeof window.name != "string") ? "Something's odd!" :
    (wname = window.name) ? wname.match(/^(.{1,15}).*/)[1].replace(/</, "&lt;") : "Dynamic",
  size = (typeof document.fileSize == "string") ? document.fileSize + " bytes" : "Navigate",
  anc = "\n<div class=\"ProxMCnt-Div\"><a class=\"ProxMLink\" target=\"",
  targP = (prxO.oMen.meSet[0] == 2) ? "_blank" : "_top",
  hasCSS = !!document.styleSheets && document.styleSheets.length > 1,
  select = anc; select += "_self\" href=\"javascript://\" onclick=\"return false;\" onmousedown=\"var q = window.getSelection || document.getSelection; q = '' + (q ? q() : document.selection.createRange().text); q = q || prompt('No text selected. &#160;Enter hostname or leave empty for current host:', ''); if (q == '' || (q == null &amp;&amp; parent.frames.length > 0)) q = '";
  select += hostA; select += "'; if (q != null) ";
  var check = anc; check += "_self\"><label class=\"ProxMLink\"><input class=\"ProxMLink\" type=\"checkbox\" value=";

  function jav(f, m, n) { return (
    anc + "_self\" href=\"javascript:prxO.oMen.meLib." + f + "();\">" + m +
    " &#" + (n || "8756") + ";</a></div>"
  ); }

  function nav(t, l) { return (
    t ? anc + "_top\" href=\"" + t + "\">" + l + "</a></div>" : ""
  ); }

  function com(m) { return (
    anc + targP + "\" href=\"" + path + amp(here.search) + "?prx-command=" +
    m + ".." + here.hash + "\">" + m + "</a></div>"
  ); }

  function rad(n, m) { return (
    anc + "_self\"><label class=\"ProxMLink\"><input class=\"ProxMLink\" " +
    "type=\"radio\" name=\"proxMMode\" " +
    ((n == Math.floor(prxO.oSet.$_level)) ? "checked=\"true\" " : "") +
    "value=\"i_level:" + n + "\" />" + m + " Mode</label></a></div>"
  ); }

  function cfg(n, m, a, b, c, d) {
    var st = prxO.oMen.meSet[n];
    return (
      check + "\"i_" + m + ":" + (st ? "-" : "") +
      "1\" /><b class=\"ProxM-B\">" + (st ? a : b) + "</b> " +
      (st ? c : d || c) + "</label></a></div>"
    );
  }

  function amp(m) { return m.replace(prxO.oAss.asReAmp, "&amp;"); }

  x[x.length] = "\n<table id=\"proxM-Table\" onmouseover=\"clearTimeout(prxO.oMen.meTimer);\" onmouseout=\"prxO.oMen.meHide();\"><tbody><tr>";

  x[x.length] = "\n<td class=\"ProxM-L-Td\">";
  x[x.length] = "\n<div class=\"ProxMSep-Div\">"; x[x.length] = wname; x[x.length] = "</div>";
  x[x.length] = anc; x[x.length] = "_self\" href=\"javascript:prxO.oInt.inToggleB('Prox','cl','span');\">Toggle Kills &#8756;</a></div>";
  x[x.length] = jav("mlTComment", "Toggle Comments");
  x[x.length] = (hasCSS ? jav("mlTStyle", "Toggle " + (document.styleSheets.length - 1) + " CSS") : "");
  x[x.length] = jav("mlDparent", "Toggle DOM Path");
  x[x.length] = jav("mlTopo", "Toggle Topo View");
  x[x.length] = anc; x[x.length] = "_self\" href=\"javascript:(function(){for(var i=0;i&lt;10000;i++){window.clearInterval(i);window.clearTimeout(i)}})();\">Kill Timers &#8756;</a></div>";

  x[x.length] = "\n<div class=\"ProxMSep-Div\">"; x[x.length] = prxO.oAss.asMode; x[x.length] = "</div>";
  x[x.length] = (hasJS ? jav("mlScripts", "Show " + hasJS + " Script" + ((hasJS > 1) ? "s" : "")) : "");
  x[x.length] = anc; x[x.length] = "_self\" href=\"javascript:void(prxO.oInt.inMyPop('"; x[x.length] = base; x[x.length] = "/local.ptron/sidki_h_"; x[x.length] = prxO.oSet.$_cfg; x[x.length] = "/shell.html',',width=676,height='+screen.height*.6));\">JavaScript Shell &#8756;</a></div>";
  x[x.length] = (!prxO.oiIsIE ? jav("mlJSvars", "JS Variables") : "");
  x[x.length] = jav("mlIDs", "Classes &amp; IDs");
  x[x.length] = jav("mlDocProps", "Doc Properties");
  x[x.length] = jav("mlDynSrc", "DOM Source", "187");

  x[x.length] = "\n<div class=\"ProxMSep-Div\">"; x[x.length] = prxO.oSet.$_cfg; x[x.length] = "</div>";
  x[x.length] = anc; x[x.length] = targP; x[x.length] = "\" href=\"http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&amp;showintro=0\">Verify Ad Lists</a></div>";
  x[x.length] = anc; x[x.length] = targP; x[x.length] = "\" href=\"http://www.geocities.com/sidki3003/prox-down.html\">Config Updates</a></div>";

  x[x.length] = "\n<div class=\"ProxMSep-Div\">Translate</div>";
  x[x.length] = anc; x[x.length] = targP; x[x.length] = "\" href=\"http://translate.google.com/translate_c?u="; x[x.length] = encodeURIComponent(url); x[x.length] = "\">Google: automatic</a></div>";
  x[x.length] = anc; x[x.length] = targP; x[x.length] = "\" href=\"http://babelfish.yahoo.com/?trurl="; x[x.length] = encodeURIComponent(url); x[x.length] = "\">BabelFish: choose</a></div>";
  x[x.length] = anc; x[x.length] = targP; x[x.length] = "\" href=\"http://www.tranexp.com:2000/Translate/index.shtml?type=url&amp;url="; x[x.length] = encodeURIComponent(url); x[x.length] = "\">InterTran: choose</a></div>";

  x[x.length] = "\n</td><td class=\"ProxM-L-Td\">";
  x[x.length] = "\n<div class=\"ProxMSep-Div\">"; x[x.length] = size; x[x.length] = "</div>";
  x[x.length] = nav(prxO.oMen.meSet[5], "Top"); x[x.length] = nav(prxO.oMen.meSet[6], "Up");
  x[x.length] = nav(document.referrer, "Referrer");

  x[x.length] = "\n<div class=\"ProxMSep-Div\">Prox</div>";
  x[x.length] = com("src"); x[x.length] = com("src..bweb"); x[x.length] = com("dbug"); x[x.length] = com("bweb"); x[x.length] = com("bypass");

  x[x.length] = "\n<div class=\"ProxMSep-Div\">Site</div>";
  x[x.length] = anc; x[x.length] = targP; x[x.length] = "\" href=\"http://validator.w3.org/check?uri="; x[x.length] = encodeURIComponent(url); x[x.length] = "&amp;ss=1&amp;sp=1&amp;noatt=1&amp;verbose=1\">Validate</a></div>";
  x[x.length] = anc; x[x.length] = targP; x[x.length] = "\" href=\"http://uptime.netcraft.com/up/graph/?host="; x[x.length] = hostA; x[x.length] = "\">Netcraft</a></div>";
  x[x.length] = anc; x[x.length] = targP; x[x.length] = "\" href=\"http://www.google.com/search?q=cache:"; x[x.length] = encodeURIComponent(url); x[x.length] = "\">Cached</a></div>";
  x[x.length] = anc; x[x.length] = targP; x[x.length] = "\" href=\"http://web.archive.org/web/*/"; x[x.length] = amp(url); x[x.length] = "\">Way Back</a></div>";
  x[x.length] = anc; x[x.length] = targP; x[x.length] = "\" href=\"http://www.alexa.com/data/details/main?url="; x[x.length] = amp(url); x[x.length] = "\">Alexa</a></div>";
  x[x.length] = anc; x[x.length] = "_self\" href=\"javascript:void(prxO.oInt.inMyPop('http://bugmenot.com/view/'+escape(&quot;"; x[x.length] = hostA; x[x.length] = "&quot;),',width=485,height=390'));\">BugMeNot &#8756;</a></div>";

  x[x.length] = "\n<div class=\"ProxMSep-Div\">Host or IP</div>";
  x[x.length] = select; x[x.length] = "(function () { var d = prxO.oInt.inMyPop('', ',width=350,height=350').document; d.write('&lt;html>&lt;head>&lt;title>All Net Tools - Loading...&lt;/title>&lt;/head>&lt;body>&lt;form name=pform method=POST action=http://www.all-nettools.com/toolbox/smart-whois.php?prx-keyword=.s_flag.>&lt;input name=ip type=hidden value=' + escape(q) + '>&lt;/form>&lt;script>window.setTimeout(&quot;document.pform.submit()&quot;,300);&lt;/script>&lt;/body>&lt;/html>'); d.close(); })(); void 0;\">SmartWhois &#8756;</a></div>";
  x[x.length] = select; x[x.length] = "prxO.oInt.inMyPop('http://samspade.org/whois?query=' + escape(q) + ';server=auto');\">Whois &#187;</a></div>";
  x[x.length] = select; x[x.length] = "prxO.oInt.inMyPop('http://www.geobytes.com/iplocator.htm?getlocation&amp;ipaddress=' + escape(q));\">Location &#187;</a></div>";

  x[x.length] = "\n</td><td id=\"proxM-R-Td\">";
  x[x.length] = "\n<div class=\"ProxMSep-Div\">Allow</div>";
  x[x.length] = "\n<form class=\"ProxMLink\" action=\"\">";
  x[x.length] = check; x[x.length] = "\"a_js\" />All JavaScript</label></a></div>";
  x[x.length] = check; x[x.length] = "\"a_ads\" />All Ads</label></a></div>";
  x[x.length] = check; x[x.length] = "\"a_adban.a_adimg\" />Ad Banners</label></a></div>";
  x[x.length] = check; x[x.length] = "\"a_adcomm1.a_adcomm2\" />Ad Comments</label></a></div>";
  x[x.length] = check; x[x.length] = "\"a_adcont.a_adtab.a_adform.a_adcss\" />Ad Containers</label></a></div>";
  x[x.length] = check; x[x.length] = "\"a_adjs\" />Ad JavaScript</label></a></div>";
  x[x.length] = check; x[x.length] = "\"a_track.a_redir\" />Trackers &amp; Redir</label></a></div>";
  x[x.length] = check; x[x.length] = "\"a_rdlink.a_jslink\" />Redir- &amp; JS-Links</label></a></div>";
  x[x.length] = check; x[x.length] = "\"a_flash.a_embed\" />Flash &amp; Media</label></a></div>";
  x[x.length] = check; x[x.length] = "\"i_ua:0.a_refer\" />UA &amp; Referrer</label></a></div>";
  x[x.length] = "\n<div class=\"ProxMSep-Div\"></div>";
  x[x.length] = cfg(1, "layout", "Alter", "Keep", "Layout");
  x[x.length] = cfg(2, "script", "Allow", "Block", "Scripts");
  x[x.length] = cfg(3, "proxy", "No", "Use", "Proxy");
  x[x.length] = cfg(4, "spoof", "Don't", "Spoof", "spoof IP", "IP");
  x[x.length] = "\n<div class=\"ProxMSep-Div\"></div>";
  x[x.length] = rad(5, "Debug"); x[x.length] = rad(4, "Advanced"); x[x.length] = rad(3, "Standard");
  x[x.length] = rad(2, "Light"); x[x.length] = rad(1, "Minimal");
  x[x.length] = "\n<input id=\"proxM-Input\" class=\"ProxMBut\" type=\"button\" value=\"Go\" onclick=\"prxO.oMen.meLib.mlForm(this.form,'go');\" />";
  x[x.length] = "\n<input class=\"ProxMBut\" style=\"width:49px\" type=\"button\" value=\"Session\" onclick=\"prxO.oMen.meLib.mlForm(this.form,'session');\" />";
  x[x.length] = "\n<input class=\"ProxMBut\" style=\"width:26px\" type=\"button\" value=\"List\" onclick=\"prxO.oMen.meLib.mlForm(this.form,'list');\" />";
  x[x.length] = "\n</form>\n</td>";

  x[x.length] = "</tr></tbody></table>";

  prxO.oMen.meDiv.innerHTML = x.join("");
  if (prxO.oSet.$_level < 5) delete prxO.oMen.meSet;
  PrxRLsetTimeout(function () { prxO.oBody.appendChild(prxO.oMen.meDiv); }, 0);
}) ();

/* ====================================
   Function library used by the menu items.
   ==================================== */

prxO.oMen.meLib = {

  // Toggle comments: Shows/hides content of comment-blocks
  // and commented-out code. - sidki
  mlTComment : function () {
    var i, it, ceci = arguments.callee;

    function walk(node) {
      var i, kids, child, tag;

      function swap(xpath) {
        var tname, targ = child.nodeValue;
        if (prxO.oSet.$_level >= 5 || targ.indexOf(" PROX") != 0) {
          tag = prxO.oInt.inMakeEl("div");
          tag.className = "Prox ProxHTag";
          targ = targ.replace(/&(?!amp;)/g, "&amp;");
          targ = targ.replace(/<(\/?script)/gi, "&lt;$1");
          tag.innerHTML = "&lt;!--" + targ + "--&gt;";
          tname = xpath ? child.parentNode.tagName : node.tagName;
          if (tname == "HEAD" || tname == "head") {
            if (!ceci.hdColl) {
              ceci.hdColl = prxO.oInt.inMakeEl("div");
              prxO.oInt.inSetCSS(ceci.hdColl,
                "position: relative; z-index: 10000; padding: 12px; " +
                "background-color: #DDEEFE; border: 1px dashed black;");
            }
            ceci.hdColl.appendChild(tag);
          } else ceci.bdColl[ceci.bdColl.length] = [tag, child];
        }
      }

      if (prxO.oiXpath) {
        kids = document.evaluate("//comment()", document, null, 0, null);
        while ((child = kids.iterateNext())) swap(1);
      } else {
        kids = node.childNodes;
        for (i = 0; child = kids[i]; i++) {
          if (child.nodeName == "#comment") swap();

          // IE6 dupes the BODY node to BASE, if present!
          else if (child.tagName != "BASE") walk(child);
        }
      }
    }

    if (ceci.done) {
      if (ceci.hdColl) {
        prxO.oBody.removeChild(ceci.hdColl);
        delete ceci.hdColl;
      }
      for (i = 0; it = ceci.bdColl[i]; i++) it[0].parentNode.removeChild(it[0]);
      delete ceci.bdColl;
    } else {
      ceci.bdColl = []; walk(document);
      if (ceci.hdColl)
        prxO.oBody.insertBefore(ceci.hdColl, prxO.oBody.firstChild);
      for (i = 0; it = ceci.bdColl[i]; i++)
        it[1].parentNode.insertBefore(it[0], it[1]);
    }
    ceci.done = !ceci.done;
  },

  // Toggle topographic view: Shows the nesting level of every element using
  // shading. - Jesse Ruderman, Joseph Pearson, sidki
  mlTopo : function () {
    var C = arguments.callee;
    if (C.css) return void (C.css.disabled = !C.css.disabled);
    if (C.done) prxO.oInt.inGetEl("head")[0].removeChild(C.tag);
    else {
      var s = "body", c = "", I = "!important;", i, b, f, x, h;
      for (i = 0; i < 17; ++i) {
        x = i.toString(16);
        b = i > 15 ? "FFCCCC" : x + x + x;
        f = i > 9 ? "000000" : "FFFFFF";
        c += s + "{background:#" + b + I + "border-color:#" + b + I + "color:#" + f + I + "}\n";
        s += " *";
      }
      if (document.createStyleSheet)
        C.css = document.createStyleSheet("javascript:'" + c + "'");
      else {
        C.tag = prxO.oInt.inMakeEl("link");
        C.tag.id = "proxTtopo";
        C.tag.rel = "stylesheet";
        C.tag.href = "data:text/css," + escape(c);
        prxO.oInt.inGetEl("head")[0].appendChild(C.tag);
      }
    }
    return void (C.done = !C.done);
  },

  // Toggle DOM path: Lists the ancestors of any element you hover over in
  // the status bar. - Jesse Ruderman, sidki
  mlDparent : function () {
    if (this.mlDtoggle) {
      window.defaultStatus = this.mlDtoggle;
      this.mlDtoggle = 0;
      document.onmouseover = PrxVoidF;
    } else {
      this.mlDtoggle = window.defaultStatus;

      function A(n, g) {
        var p = n.parentNode, t = n.tagName, x, y;
        if (!p) return "";
        for (y = 0, x = n.previousSibling; x; x = x.previousSibling)
          if (x.nodeName == n.nodeName) y++;
        if (!t) return A(p, g);
        var T = t.toUpperCase(), b = (T != "TABLE" &&
          T != "TBODY" && T != "THEAD" && T != "TR"), c = n.className, i = n.id;
        return A(p, " > ") + (b ? T : T.toLowerCase()) + (y ? "[" + (y + 1) + "]" : "") + (c ? "." + c : "") + (i ? "#" + i : "") + (b ? g : " ");
      }

      function over(e) {
        e = e || window.event;
        var s, g = e.target || e.srcElement;
        try { s = A(g, ""); }
        catch (er) { s = er.message; }
        window.defaultStatus = s + "";
        return true;
      }

      document.onmouseover = over;
      window.defaultStatus = A(document.documentElement, "");
    }
  },

  // Toggle stylesheets. - sidki, Jesse Ruderman
  mlTStyle : function () {
    var h, i, d, j = 0, o, x = document.styleSheets;
    for (i = 0; i < x.length; i++) {
      d = x[i];
      if (d.disabled) d.disabled = 0;
      else {
        o = d.owningElement || d.ownerNode; h = d.href;
        if (o.id.indexOf("prox") != 0) {
          d.disabled = 1;
          if (!arguments.callee.done)
            prxO.oInt.inFooter(3, "style " + ++j, (o.tagName == "STYLE") ? "inline" : h);
        }
      }
    }
    arguments.callee.done = true;
  },

  // Show all JavaScript variables and functions. - Jesse Ruderman
  mlJSvars : function () {
    var i, v, st, preB = prxO.oiIsOp ? "-o-pre-wrap" : "pre",
    r = prxO.oiIsOp ? /^(Prx|pr(o|)x| PROX:)/ : /^Prx|^prx|onerror/,
    x = prxO.oInt.inMyPop("", ",width=600,height=400"), d = x.document;
    d.open();

    function htmlEsc(s) {
      s = s.replace(/&/g, "&amp;");
      s = s.replace(/>/g, "&gt;");
      s = s.replace(/</g, "&lt;");
      return s;
    }

    d.write(
      "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n\"http://www.w3.org/TR/html4/strict.dtd\">" +
      "\n<html>\n<head>\n<title>All JS Variables and Functions</title>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">" +
      "\n<style type=\"text/css\">\nbody,td{font:12px/15px Verdana,Arial,sans-serif;color:#313131;background:#CEDFEF;}" +
      "\ntd{vertical-align:top;white-space:" + preB +
      ";}\ntable,td,th{border:1px solid #91BBE3;}\nth.string{text-align:left;padding-left:100px;}\ndiv.er{color:red;}\n</style>" +
      "\n</head>\n<body>\n<table border=\"1\" summary=\"\">\n<thead><tr><th>Variable</th><th>Type</th><th class=\"string\">Value as string</th></tr></thead>\n"
    );
    for (i in window)
      if (!(i in x) && (!r.test(i) || prxO.oSet.$_level >= 5)) {
        d.write("<tr><td>" + htmlEsc(i) + "</td><td>" + htmlEsc(typeof window[i]) + "</td><td>");
        if ((v = window[i]) === null) d.write("null");
        else if (v === undefined) d.write("undefined");
        else {
          var e1 = "<div class=\"er\">", e2 = "</div>\n";
          try {
            st = v.toString();
            d.write(st.length ? htmlEsc(st) : "\xA0");
          } catch (er) {
            d.write(e1 + htmlEsc(er.toString()) + e2);
          }
        }
        d.write("</td></tr>\n");
      }

    d.write("</table>\n</body>\n</html>\n");
    d.close();
  },

  // Show all classes and IDs used in the document. - Jesse Ruderman, sidki
  mlIDs : function () {
    var a = {}, aa = {}, b = [], bb = [], i, pxC, pxI, pxCs, pxIs, pxT, pxB,
    pxA = prxO.oInt.inGetEl("*"),
    pxD  = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n\"http://www.w3.org/TR/html4/strict.dtd\">";
    pxD += "\n<html>\n<head>\n<title>All Classes and IDs</title>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">";
    pxD += "\n<style type=\"text/css\">\nbody,td{font:12px/15px Verdana,Arial,sans-serif;color:#313131;background:#CEDFEF;}";
    pxD += "\ntable,td,th{border:1px solid #91BBE3}\ntable{float:left;margin-right:8px}\n</style>";
    pxD += "\n</head>\n<body>\n<table border=1 summary=\"\">\n<thead><tr><th>#</th><th>Tag</th><th>className</th></tr></thead>\n";
    for (i = 0; pxT = pxA[i]; i++) {
      pxC = pxT.className;
      if (pxC && (prxO.oSet.$_level >= 5 || pxC.indexOf("Prox") != 0)) {
        pxCs = pxT.tagName; pxCs += "."; pxCs += pxC;
        a[pxCs] = a[pxCs] ? ++a[pxCs] : 1;
      }
      pxI = pxT.id;
      if (pxI && typeof pxI == "string" && (prxO.oSet.$_level >= 5 || pxI.indexOf("prox") != 0)) {
        pxIs = pxT.tagName; pxIs += "."; pxIs += pxI;
        aa[pxIs] = aa[pxIs] ? ++aa[pxIs] : 1;
      }
    }
    for (pxCs in a) b[b.length] = [pxCs, a[pxCs]];
    b.sort();
    for (i = 0; pxB = b[i]; i++)
      pxD += "<tr><td>" + pxB[1] + "</td><td>" + pxB[0].split(".").join("</td><td>") + "</td></tr>\n";
    pxD += "</table>\n";
    pxD += "<table border=1 summary=\"\">\n<thead><tr><th>#</th><th>Tag</th><th>ID</th></tr></thead>\n";
    for (pxIs in aa) bb[bb.length] = [pxIs, aa[pxIs]];
    bb.sort();
    for (i = 0; pxB = bb[i]; i++)
      pxD += "<tr><td>" + pxB[1] + "</td><td>" + pxB[0].split(".").join("</td><td>") + "</td></tr>\n";
    pxD += "</table>\n</body>\n</html>\n";
    var d = prxO.oInt.inMyPop("", ",width=520,height=500").document;
    d.write(pxD);
    d.close();
  },

  // Show linked and embedded scripts.  Proxomitron's standard scripts are
  // not displayed. - Jesse Ruderman, sidki
  mlScripts : function () {
    var d = prxO.oInt.inMyPop("", ",width=800,height=" + screen.height * .7).document;
    d.open();
    var ti = "Scripts in " + location.href;
    d.write(
      "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n\"http://www.w3.org/TR/html4/strict.dtd\">" +
      "\n<html>\n<head>\n<title>" + ti + "</title>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">" +
      "\n<style type=\"text/css\">\nbody{margin:20px;font:12px/20px Verdana,Arial,sans-serif;color:#313131;background:#CEDFEF;}" +
      "\nh2{font-size:18px;}\nh4{margin:22px 0 6px 0;font-size:12px;}\npre{margin:4px 0 4px 0;}" +
      "\niframe{width:100%;height:27em;border:1px solid;background:#DDEEFE;}\n</style>" +
      "\n</head>\n<body>\n<h2>" + ti + "</h2>\n"
    );

    var i, si, ifr, r_src, b_for, blk, s = prxO.oInt.inGetEl("script"),
      rgx = prxO.oiIsIE ? /\.(aspx|js|vbs)(\b)/gi : prxO.oiIsMoz ? /\.(json|vbs)(\b)/gi : null;

    function trim(s) {
      return s.replace(/^\s*\n/, "").replace(/\s*$/, "").replace(/</g, "&lt;");
    }

    function query(s) {
      if (s) r_src = r_src.replace(rgx, ".$1prox$2");
      var anc = r_src.indexOf("#"), que = "?prx-sniff:proxov&prx-ref:";
      if (anc != -1) r_src = r_src.substring(0, anc) + que + r_src.substr(anc);
      else r_src += que;
    }

    for (i = 0; si = s[i]; i++) {
      if (si.id.indexOf("proxScr") == 0) continue;
      r_src = si.src; blk = "";
      if (r_src) {
        if (r_src.search(/\/dummy.js|prxCountAd|void%200/) != -1) {
          b_for = prxO.oiIsOp ? si.getAttribute("for") : si.htmlFor;
          if (b_for) {
            if (b_for == "nested") {
              r_src = "";
              d.write("<h4>Blocked 2nd level script</h4>");
            } else {
              r_src = b_for;
              blk = "Blocked ";
            }
          } else {
            r_src = "";
            d.write("<h4>Blocked inline script</h4><pre>" + trim(si.text) + "</pre>");
          }
        }
        if (r_src) {
          d.write('<h4>' + blk + 'script src="' + r_src + '"</h4>');
          if (prxO.oiIsIE) {
            if (r_src.indexOf("?prx-sniff:") != -1) continue;
            query(1);
          }
          else if (prxO.oiIsMoz && rgx.test(r_src)) query(1);
          else if (blk) query();
          d.write("<iframe src='" + r_src + "'></iframe>");
        }
      }
      else d.write("<h4>Inline script</h4><pre>" + trim(si.text) + "</pre>");
    }
    d.write("\n</body>\n</html>\n");
    d.close();
  },

  // Show DOM source: Displays the DOM tree of the page as HTML.
  // - Jesse Ruderman, sidki
  mlDynSrc : function () {

    function hiLight(s) {
      s = s.replace(/&/g, "&amp;");
      s = s.replace(/(\s|\n)([a-z][^\s=]*\s?=\s?)("[^"\n]*"|'[^'\n]*'|[^<>\s\n]*)/gi,
                    "$1_pxO-b-i$2_pxC-b-_pxO-b-q$3_pxC-b-");
      s = s.replace(/<(!--(?:(?:.|\r|\n)+?)-- ?)(?=>)/g, "_pxO-span-c&lt;$1_pxC-span-");
      s = s.replace(/<([!a-z][a-z0-9]*( ?\/?(?=>))?|\/[^->]+(?=>)|)/gi, "_pxO-b-t&lt;$1_pxC-b-");
      s = prxO.oiIsOp ?
        s.replace(/>\n?/g, "_pxO-b-t&gt;_pxC-b-\n") :
        s.replace(/>/g, "_pxO-b-t&gt;_pxC-b-");
      s = s.replace(/_pxO-([^-]+)-(.)/g, '<$1 class="$2">');
      s = s.replace(/_pxC-([^-]+)-/g, "</$1>");
      return s;
    }

    var d = prxO.oInt.inMyPop("").document;
    d.write(
      "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n\"http://www.w3.org/TR/html4/strict.dtd\">" +
      "\n<html>\n<head>\n<title>Dynamic Source</title>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />" +
      "\n<link rel=\"stylesheet\" type=\"text/css\" href=\"http://local.ptron/ViewSrc.css\" />" +
      "\n<style type=\"text/css\">\nspan.c{color:gray;}\n</style>" +
      "\n</head>\n<body>\n<pre>\n\n" + hiLight("<html>" + document.documentElement.innerHTML + "</html>") + "\n</pre>\n</body>\n</html>"
    );
    d.close();
  },

  // Get various information about the currently displayed document.
  // - Paul Rupe
  mlDocProps : function () {
    var i, j, imI, liI, imC = 0, liC = 0, imO = document.images, liO = document.links,
    al = (prxO.oSet.$toDo & 4) ? PrxRLalert : alert;
    for (i = 0; imI = imO[i]; i++)
      if (imI.className.indexOf("Prox") == 0 || imI.id.indexOf("prox") == 0) imC++;
    for (j = 0; liI = liO[j]; j++)
      if (liI.className.indexOf("Prox") == 0) liC++;
    al(
      "Window name: " +  (window.name || "none") +
      "\nLast modified: " + document.lastModified +
      "\nFrames: " + (frames.length) +
      "\nImages: " + (imO.length - imC) +
      "\nLinks: " + (liO.length - liC) +
      "\nForms: " + (document.forms.length - 1) +
      "\nEmbedded objects: " + document.embeds.length + "\n"
    )
  },

  // Say what should happen when clicking the menu buttons. - JD, sidki
  mlForm : function (form, what) {
    var i, f, all ="", here = window.location, el = form.elements;

    for (i = 0; f = el[i]; i++)
      if (f.checked && f.value != "i_level:" + prxO.oSet.$_level) all += f.value + ".";

    switch (what) {
      case "go" :
        all = all ? "?prx-keyword=." + all : "";
        var query = here.search.match(/^(.*)\?prx-keyword=/);
        query = !query ? here.search : query[1];
        here.href = here.protocol + "//" + here.host + here.pathname +
          query + all + here.hash;
        break;

      case "list" :
        all = all || "YOUR_WORD.";
        var hostR = here.hostname.match(/^https\.\.(.+)/)
        hostR = hostR ? hostR[1] :
          ((here.protocol == "https:" && !here.port) ?
          (here.hostname + ":443") : here.host);
        here.href = "http://add.to.proxlist/" + hostR +
          here.pathname.match(/^\/([^\/]+\/)*/g) +
          "$$$SET(0=" + all + ")$$" + here.href;
        break;

      case "session" :
        here.href = "http://add.to.memlist/" +
          "$SET(a=" + all + ")PrxFail$TST()$$" + here.href;
    }
  }

};
